/**
 * Created by HUANGFR2 on 8/22/2016.
 */
angular.module('order_complaint').service('ComplaintService', function ($http) {
    var service ={
        updateComplaintStatus : function (complaint, status) {
            $http.put('/complaint', {oid : complaint._id, status : status})
                .then(function (res) {
                    var data = res.data;
                    if(data.msg == 'SUCCESS'){
                        complaint.status = status;
                    } else {
                        alert('operation error : ' + data.error);
                    }
                }, function (res) {
                    alert('operation error : ' + res.error);
                })
        }
    };
    return service;
});

angular.module('order_complaint').filter('convertComplaintStatus', function () {
    return function (status) {
        switch (status){
            case 0 : return 'Pending';
            case 1 : return 'Dismiss complaint';
            case 2 : return 'Deduct deposit';
            case 3 : return 'Block Merchant';
        }
    }
});